#ifndef VIDEOANALYSISSYSTEM_VAS_ZK_H
#define VIDEOANALYSISSYSTEM_VAS_ZK_H

#include <sstream>
#include <zookeeper/zookeeper.h>
#include "vas_utils.h"
#include "vas_do.h"
#include "vas_exception.h"


namespace vas {
    const char CHANNEL_ROOT[] = "/channel";
    const char HANDLE_NODE[] = "vas_handling";

    zhandle_t *ZookeeperInit(const std::string &host, bool *running, const char *channel_root);

    void ChannelRootWatcher(zhandle_t *zh, int type, int state, const char *path, void *watcherCtx);

    void ChannelHandleWatcher(zhandle_t *zh, int type, int state, const char *path, void *watcherCtx);

    Channel
    GetOneWaitingChannel(zhandle_t *zh, const char *channel_root, const char *handle_node, void *handle_watch_ctx);

    void ZookeeperStop(zhandle_t *zh);

    std::string
    GetChannelFromHandlePath(const std::string &path, const std::string &channel_root, const std::string &handle_node);

}


#endif //VIDEOANALYSISSYSTEM_VAS_ZK_H
